package com.junlinpro.utils;


import io.netty.channel.Channel;
import io.netty.channel.socket.SocketChannel;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class SocketChannelMap {

    // 开始任务id前缀
    public static final String startTaskKey = "start_";
    // 结束任务id前缀
    public static final String stopTaskKey = "stop_";
    
    // dp任务id前缀
    public static final String dpTaskKey = "dp_";

    // 储存维护心跳的链接对象
    private static Map<String, Channel> heartbeatChannelMap = new ConcurrentHashMap<>();

    private static Map<String, Channel> mChannelMap = new ConcurrentHashMap<>();

    // 储存开始和结束监听是否成功状态
    private static Map<String, Boolean> taskMap = new ConcurrentHashMap<>();
    
    // 储存监听的采集卡
    private static Map<String, Boolean> monitorTaskMap = new ConcurrentHashMap<>();
    
    public static void monitorTaskMapPut(String key, Boolean value) {
    	monitorTaskMap.put(key, value);
    }

    public static Boolean monitorTaskMapGet(String key) {
        return monitorTaskMap.get(key);
    }

    public static void monitorTaskMapRemove(String key) {
    	monitorTaskMap.remove(key);
    }

    public static void taskMapPut(String key, boolean value) {
        taskMap.put(key, value);
    }

    public static boolean taskMapGet(String key) {
        return taskMap.get(key);
    }

    public static void taskMapRemove(String key) {
        taskMap.remove(key);
    }

    public static void add(String cardId, Channel channel) {
        //if(!mChannelMap.containsKey(cardId)) {
        mChannelMap.put(cardId, channel);
        // }
    }

    public static Channel get(String cardId) {
        return mChannelMap.get(cardId);
    }

    public static void heartbeatChannelMapAdd(String cardId, Channel channel) {
        heartbeatChannelMap.put(cardId, channel);
    }

    public static Map<String, Channel> getHeartbeatChannelMap() {
        return heartbeatChannelMap;
    }

}
